package com.lagou.homework4;

import com.lagou.task16.AgeException;

public class Worker {
    private String name;
    private int age;

    public Worker() {
    }

    public Worker(String name, int age) {
        if (age < 150 && age > 18){
            this.age = age;
        }else {
            try {
                throw new Exception("年龄不符合规定");
            }catch (Exception e){
                e.printStackTrace();
            }
        }
        if (name == null || name.isBlank()){
            try {
                throw new Exception("姓名不能为null或者\"\"");
            }catch (Exception e){
                e.printStackTrace();
            }
        }else{
            this.name = name;
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
